package code.util;

import java.io.File;
import java.io.IOException;
import java.util.Locale;

import freemarker.template.Configuration;
import freemarker.template.TemplateExceptionHandler;

public class FreemarkerConfiguration {

	private static Configuration configuration;
	
	public static Configuration getConfigurationInstance() throws IOException{
		if(configuration == null){
			configuration = new Configuration();
			configuration.setDirectoryForTemplateLoading(new File(System.getProperty("user.dir") + "/src/main/resources/templates"));
			configuration.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
			configuration.setDefaultEncoding(EnvConstants.ENCODING);
			configuration.setLocale(Locale.CHINESE);
		}
		return configuration;
	}
}
